﻿using Microsoft.AspNetCore.Http;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using AnlianCommon.Common.Domains.BankCustomers;
using AnlianCommon.Common.DTO;
using AnlianCommon.Enum;
using SheepCommon.API.SheepSelles;
using Yitter.IdGenerator;

namespace SheepCommon.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SheepSellsController : ControllerBase
    {
        private readonly IMediator _mediator;

        public SheepSellsController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 销售新增
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> SheepSellCreate(SheepSellCreateCommand request, CancellationToken cancellationToken)
        {
            //单据号
            request.DocumentNumber = YitIdHelper.NextId().ToString();
            var result = await _mediator.Send(request);
            return result;
        }
        /// <summary>
        /// 销售列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultPage<SheepSellQueryDto>> SheepSellQuery(SheepSellQueryCommand request, CancellationToken cancellationToken)
        {
            var result = await _mediator.Send(request);
            return result;
        }
    }
}
